<?php

include "../../lib/start.php";

check_session();
check_permission(ADM_PERM);

$offset = $_REQUEST['offset'];

if($_REQUEST['area'] == "admin")
	$opener = "index.php";
else
	$opener = "../../intranet/manager/school_docs.php";

$sel_anni = "SELECT * FROM anni ORDER BY id_anno DESC";
$res_anni = $db->executeQuery($sel_anni);

$sel_sedi = "SELECT * FROM sedi";
$res_sedi = $db->executeQuery($sel_sedi);

$sel_gruppi = "SELECT * FROM gruppi ORDER BY nome";
$res_gruppi = $db->executeQuery($sel_gruppi);

if(isset($_REQUEST['id']) && $_REQUEST['id'] != 0){
    // modifica
    $sel_doc = "SELECT * FROM documents WHERE id = ".$_REQUEST['id'];
    $res_doc = $db->executeQuery($sel_doc);
    $doc = $res_doc->fetch_assoc();
	$array_gruppi = explode(",", $doc['gruppi']);
    $_i = $_REQUEST['id'];
}
else{
    // nuovo progetto
    $_i = 0;
}

include "dettaglio_documento.html.php";

?>